<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI
class Utils extends CI_Controller {

 function __construct() {
   parent::__construct();
   $this->load->model('movements_model');
 }

 /*function index() {
   if($this->session->userdata('logged_in')) {
     $session_data = $this->session->userdata('logged_in');
     $data['ds_nick'] = $session_data['ds_nick'];
     $this->load->view('home_view', $data);
   } else {
     redirect('login', 'refresh');
   }
 }*/

 function logout() {

  $session_data = $this->session->userdata('logged_in');
  $idUser = $session_data['id_usuario'];
  $idCountry = $session_data['id_pais'];
  $timezone = new DateTimeZone("UTC");
  $date = new DateTime("now", $timezone);
  $date = $date->format("Y-m-d\TH:i:s");
  $this->movements_model->savemovement('12', $idUser, $idCountry, $date) ;

  $this->session->unset_userdata('logged_in');
  session_destroy();
  redirect('login', 'refresh');
  //header('location: login');
 }

}

?>